#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=500000;

long long min(long long a, long long b) {
  return a<b ? a : b;
}

long long max(long long a, long long b) {
  return a>b ? a : b;
}

class SegmentTree {
public:
  long long maxv[4*maxn+1], mark[4*maxn+1];

  void markDown(int o, int l, int r) {
    if (mark[o]) {
      if (l!=r) {
	mark[o*2] += mark[o];
	mark[o*2+1] += mark[o];
      }
      maxv[o] += mark[o];
      mark[o] = 0;
    }
  }

  void add(int o, int l, int r, int tl, int tr, long long tv) {
    markDown(o, l, r);
    if (l==tl && r==tr) {
      mark[o] += tv;
      markDown(o, l, r);
    } else {
      int mid=(l+r)/2;
      if (tl<=mid && tr>=l) {
	add(o*2, l, mid, max(tl, l), min(tr, mid), tv);
      }
      if (tl<=r && tr>mid) {
	add(o*2+1, mid+1, r, max(tl, mid+1), min(tr, r), tv);
      }
      markDown(o*2, l, mid);
      markDown(o*2+1, mid+1, r);
      maxv[o] = max(maxv[o*2], maxv[o*2+1]);
    }
  }
};

class Tree {
public:
  int n, m, vol, ind[maxn+1], link[2*maxn-1], to[2*maxn-1], val[2*maxn-1], dfn[maxn+1], l[maxn+1], r[maxn+1];
  bool flag[maxn+1];
  SegmentTree dis;

  void addSide(int u, int v, int w) {
    m++;
    to[m] = v;
    val[m] = w;
    link[m] = ind[u];
    ind[u] = m;
  }

  long long build(int o, int fa, int dep) {
    l[o] = n, r[o] = 0;
    if (flag[o]) {
      l[o] = r[o] = dfn[o] = ++dfn[0];
      dis.add(1, 1, vol, dfn[o], dfn[o], dep);
    }
    long long ret=0;
    for (int i=ind[o]; i; i=link[i]) {
      if (to[i]!=fa) {
	ret += build(to[i], o, dep+val[i]);
	l[o] = min(l[o], l[to[i]]);
	r[o] = max(r[o], r[to[i]]);
	if (l[to[i]]<=r[to[i]]) {
	  ret += val[i];
	}
      }
    }
    return ret;
  }

  void solve(int o, int fa, long long sum, long long ans[]) {
    ans[o] = sum*2-dis.maxv[1];
    for (int i=ind[o]; i; i=link[i]) {
      if (to[i]!=fa) {
	dis.add(1, 1, vol, 1, vol, val[i]);
	dis.add(1, 1, vol, l[to[i]], r[to[i]], -2*val[i]);
	solve(to[i], o,
	      l[to[i]]<=r[to[i]] ?
	      (vol>r[to[i]]-l[to[i]]+1 ?
	       sum
	       : sum-val[i])
	      : sum+val[i]
	      , ans);
	dis.add(1, 1, vol, l[to[i]], r[to[i]], 2*val[i]);
	dis.add(1, 1, vol, 1, vol, -val[i]);
      }
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static Tree tree;
  int n, k;
  scanf("%d %d", &n, &k);
  tree.n = n, tree.vol = k;
  for (int i=1; i<n; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    tree.addSide(x, y, z);
    tree.addSide(y, x, z);
  }

  for (int i=1; i<=k; i++) {
    int t;
    scanf("%d", &t);
    tree.flag[t] = true;
  }

  static long long ans[maxn+1];
  tree.solve(1, 0, tree.build(1, 0, 0), ans);
  for (int i=1; i<=n; i++) {
    printf("%lld\n", ans[i]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
